package com.hk.core.jdbc;

import com.hk.commons.query.AndOr;
import com.hk.core.jdbc.query.CompositeCondition;
import com.hk.core.jdbc.query.Condition;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.Collection;

/**
 * 删除参数
 *
 * @author kevin
 * @date 2018-09-19 14:01
 */
@Data
@Accessors(chain = true)
@NoArgsConstructor
public final class DeleteArguments {

    /**
     * 要删除的表名
     */
    private String from;

    /**
     * 条件 where conditions
     */
    private CompositeCondition conditions = new CompositeCondition();

    public DeleteArguments addCondition(Condition condition) {
        conditions.addConditions(condition);
        return this;
    }

    public DeleteArguments addConditions(Condition... conditions) {
        this.conditions.addConditions(conditions);
        return this;
    }

    public DeleteArguments addConditions(Collection<? extends Condition> conditions) {
        this.conditions.addConditions(conditions);
        return this;
    }

    public DeleteArguments removeCondition(Condition condition) {
        conditions.removeCondition(condition);
        return this;
    }

    public DeleteArguments clearConditions() {
        conditions.clearConditions();
        return this;
    }

    public DeleteArguments removeCondition(int index) {
        conditions.removeCondition(index);
        return this;
    }

    public DeleteArguments andOr(AndOr andOr) {
        conditions.setAndOr(andOr);
        return this;
    }
}
